<?php
namespace app\index\controller;

use app\common\tool\Query;
use app\common\tool\Tool;
use app\common\model\Config as ConfigModel;
use think\Config;
use think\Request;

class FrontBase{

    protected $param = [];

    public function __construct(){
        $query = new Query();
        $this->param['query'] = $query;
        $this->param['path'] = request()->path();
        $this->param['config'] = ConfigModel::all();
        $this->param['config'] = collection($this->param['config'])->toArray();
        $tool =new Tool();
        $this->param['config'] = $tool->changeArrayKey($this->param['config'],'ckey');
        $this->param['tool'] = $tool;
        $this->param['param'] = request()->param();
        $this->param['get'] = request()->get();
        $this->param['post'] = request()->post();
        $this->param['is_mobile'] = $tool->isMobile();

        //面包屑导航
        $breadcrumbs = Config::get("breadcrumbs");
        if(!empty($breadcrumbs[$this->param['path']])){
            $breadcrumbs = $breadcrumbs[$this->param['path']];
        }

        $this->param['breadcrumbs'] = $breadcrumbs;
    }
}